ActiveAdmin.register AppointedOverview do
  menu label: '预约概况', parent: '数据统计'

  actions :index
  filter :company, label: '集团'
  controller do
    def index
      index! do |format|
        format.html {render 'admin/appointed_overviews/index', layout: 'active_admin'}
      end
    end

    def data
      render json: {
          total: AppointedOverview.count,
          rows: AppointedOverview.page(params[:page]||1).map {|r|
            {
                report_date: r.report_date,
                company: r.company,
                member_type: r.member_type,
                member_count: r.member_count,
                free_appointed: r.free_appointed,
                tuition_appointed: r.tuition_appointed,
                free_course_appointed: r.free_course_appointed,
                tuition_course_appointed: r.tuition_course_appointed,
                free_avg: r.free_avg,
                tuition_avg: r.tuition_avg

            }}
      }
    end
  end
end
